__global__ void  processAxisOri(AxisOrientation_t* d_axisOri)
{
	int index = blockIdx.x * blockDim.x + threadIdx.x, i = 0;
	double distance = 0.0;
	bool notFound = true;
	
	do
	{
		//don't revote
		if(i != index)
		{
			if((int)(d_axisOri[index].a/10000) == (int)(d_axisOri[i].a/10000) &&
			   (int)(d_axisOri[index].b/10000) == (int)(d_axisOri[i].b/10000) &&
			   (int)(d_axisOri[index].c/10000) == (int)(d_axisOri[i].c/10000) &&
			   d_axisOri[index].a != 0)
			{
				atomicAdd(&d_axisOri[i].votes, 1);//++;
				notFound = false;
 
 				// add everything up, the average will be taken in the following
				// kernel
				atomicAdd(&d_axisOri[i].a, d_axisOri[index].a);
				atomicAdd(&d_axisOri[i].b, d_axisOri[index].b);
				atomicAdd(&d_axisOri[i].c, d_axisOri[index].c);
				atomicAdd(&d_axisOri[i].alpha, d_axisOri[index].alpha);
				atomicAdd(&d_axisOri[i].beta, d_axisOri[index].beta);
				atomicAdd(&d_axisOri[i].theta, d_axisOri[index].theta);

			}
		}
		else
			notFound = false;
			
		i++;
		
	}while(notFound && i < AO_HIGH);
}
